import { memo } from "react";


const Pagination = memo((props)=>{
    
    const pageNums = []
    for (let i=1 ; i<=Math.ceil(props.count/2);i++) {
          pageNums.push(i)  
    }

    return(
        <nav>
            <ul>
                {
                    pageNums.map(pageNum=>{
                        const isCurrentPage = pageNum === props.current
                        return(
                            <li key={pageNum} className={isCurrentPage ? 'page-item active' : 'page-item' } >
                                <button type="button" className="page-link" >
                                    {pageNum}
                                </button>
                            </li>
                        )
                    })
                }
            </ul>
        </nav>
    )
})

export default Pagination